package com.songlanyun.modules.config.service.impl;

import com.songlanyun.common.exception.RRException;
import com.songlanyun.modules.exception.ConfigException;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.songlanyun.common.utils.PageUtils;
import com.songlanyun.common.utils.Query;

import com.songlanyun.modules.config.dao.SystemUserRoleConfigDao;
import com.songlanyun.modules.config.entity.SystemUserRoleConfigEntity;
import com.songlanyun.modules.config.service.SystemUserRoleConfigService;


@Service("yxtSystemUserRoleConfigService")
public class SystemUserRoleConfigServiceImpl extends ServiceImpl<SystemUserRoleConfigDao, SystemUserRoleConfigEntity> implements SystemUserRoleConfigService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<SystemUserRoleConfigEntity> page = this.page(
                new Query<SystemUserRoleConfigEntity>().getPage(params),
                new QueryWrapper<SystemUserRoleConfigEntity>()
        );

        return new PageUtils(page);
    }

    /**
     * 是否报错
     * @param id
     * @param isThrow
     * @return
     */
    @Override
    public SystemUserRoleConfigEntity getById(Integer id, boolean isThrow) {
        SystemUserRoleConfigEntity entity = this.getById(id);
        if (entity == null) {
            if (isThrow) {
                throw new RRException(ConfigException.CONFIG_NOT_EXIST);
            }
        }
        return entity;

    }

}
